package org.hiucung.hlsdownloader.database

import kotlinx.coroutines.flow.Flow

// M3U8TaskRepository.kt
class M3U8TaskRepository(private val downloadItemDao: M3U8TaskItemDao) {
    val allItems: Flow<List<M3U8TaskItemEntity>> = downloadItemDao.getAll()

    suspend fun getItemById(id: String): M3U8TaskItemEntity? {
        return downloadItemDao.getById(id)
    }

    suspend fun insertItem(item: M3U8TaskItemEntity) {
        downloadItemDao.insert(item)
    }

    suspend fun updateItem(item: M3U8TaskItemEntity) {
        downloadItemDao.update(item)
    }

    suspend fun deleteItem(item: M3U8TaskItemEntity) {
        downloadItemDao.delete(item)
    }

    suspend fun deleteItemById(id: String) {
        downloadItemDao.deleteById(id)
    }
}